package com.eden.door.view;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JTable;

public class DoorViewPanel extends JPanel {
	
	private static final long serialVersionUID = 1L;
	private JTable table;
	private JScrollPane fieldScrollPane;
	private JPanel fieldPanel;
	private JScrollPane tableScrollPane;
	private JPanel tablePanel;
	
	/**
	 * Create the panel.
	 */
	public DoorViewPanel() {
		setLayout(new GridLayout(0, 1, 0, 0));
		
		fieldScrollPane = new JScrollPane();
		add(fieldScrollPane);
		
		fieldPanel = new JPanel();
		fieldScrollPane.setViewportView(fieldPanel);
		fieldPanel.setLayout(new FlowLayout(FlowLayout.LEFT , 10 , 15)) ;
		
		fieldPanel.setPreferredSize(new Dimension(400 , 200)) ;
		
		tableScrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED , JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		
		
		tablePanel = new JPanel();
		
		tablePanel.setLayout(new BorderLayout(0, 0));
		
		table = new JTable(new Object[][]{{1,2},{2,4}} ,new Object[] {
				"1", "New column"
			});
		
	
		tableScrollPane.setViewportView(table);
		add(tableScrollPane);
		
	}

	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		fieldScrollPane.setPreferredSize(fieldScrollPane.getParent().getSize()) ;
//		System.out.println(sp.getSize() ) ;
//		System.out.println(sp.getParent().getSize() ) ;
		
	}

	
	
	public JTable getTable() {
		return table;
	}

	public void setTable(JTable table) {
		this.table = table;
	}

	public JScrollPane getFieldScrollPane() {
		return fieldScrollPane;
	}

	public void setFieldScrollPane(JScrollPane fieldScrollPane) {
		this.fieldScrollPane = fieldScrollPane;
	}

	public JPanel getFieldPanel() {
		return fieldPanel;
	}

	public void setFieldPanel(JPanel fieldPanel) {
		this.fieldPanel = fieldPanel;
	}

	public JScrollPane getTableScrollPane() {
		return tableScrollPane;
	}

	public void setTableScrollPane(JScrollPane tableScrollPane) {
		this.tableScrollPane = tableScrollPane;
	}

	public JPanel getTablePanel() {
		return tablePanel;
	}

	public void setTablePanel(JPanel tablePanel) {
		this.tablePanel = tablePanel;
	}
	

}
